package com.neusoft.bizcore.file.converter;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

import com.neusoft.bizcore.file.dto.FileDTO;
import com.neusoft.bizcore.file.model.FileDocument;

@Component
@ConditionalOnClass(MongoTemplate.class)
public class MongoFileConverter {
    public FileDTO toDTO(final FileDocument doc) {
        final FileDTO dto = new FileDTO();
        dto.setId(doc.getId());
        dto.setName(doc.getName());
        dto.setSize(doc.getSize());
        dto.setUploadDate(doc.getUploadDate());
        dto.setMd5(doc.getMd5());
        dto.setContentType(doc.getContentType());
        dto.setSuffix(doc.getSuffix());
        dto.setDescription(doc.getDescription());
        dto.setFsId(doc.getFsId());
        return dto;
    }

}
